package com.example.cameraapp.fragment;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class MyMenuFragmentAdapter extends FragmentPagerAdapter {

    private final int PAGER_COUNT = 1;
    private List<MyMenuFragment> myMenuFragmentList = new ArrayList<>();

    public MyMenuFragmentAdapter(FragmentManager fm) {
        super(fm);
        myMenuFragmentList.add(new MyMenuFragment("","选项二","选项三","选项四","选项五","选项六","选项七","选项八"));
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        System.out.println("there will no fragment be destroyed");
        super.destroyItem(container, position, object);
    }

    @Override
    public Fragment getItem(int position) {
        return myMenuFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return PAGER_COUNT;
    }
}
